package com.clstu.stringBuffer;

public class StringBufferAndString {
    public static void main(String[] args) {
        String s="hello world";
        //String --> StringBuffer
        StringBuffer stringBuffer = new StringBuffer(s);// way 1
        StringBuffer stringBuffer1 = new StringBuffer();
        stringBuffer1.append(s);//way 2

        //StringBuffer --> String
        String s1=stringBuffer1.toString();//way 1
        String s2=new String(stringBuffer);//say 2 构造器版本，直接接受一个StringBuffer类的对象
        System.out.println(s1);
        System.out.println(s2);

    }
}
